package com.thinkgem.jeesite.modules.sys.helper;

import java.util.HashMap;
import java.util.Map;

import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.exception.ParamException;

public class TerminalServiceHelper {

	private TerminalServiceHelper() {

	}

	private static TerminalServiceHelper instance;

	public static TerminalServiceHelper getInstance() {
		if (instance != null) {
			return instance;
		}
		instance = new TerminalServiceHelper();
		return instance;
	}

	private Map<String, String> serviceMap = new HashMap<String, String>();

	public Map<String, String> getServiceMap() {
		return serviceMap;
	}

	public void add(String handlerType, String serviceName) {
		serviceMap.put(handlerType, serviceName);
	}

	public String getService(String handlerType) throws ParamException {
		String serviceName = serviceMap.get(handlerType);
		if (StringUtils.isEmpty(serviceName)) {
			throw new ParamException("请求类型[" + handlerType + "]不存在，请确认后重试");
		}
		return serviceName;
	}

}
